<?php
	require("header.php");
	if($userType === "admin") { 
		header("location: access_error.php");
	}
?>
<div id="content">
  <div id="content-header">
    <div id="breadcrumb"> <span><i class="icon-home"></i> 问题单管理 </span></div>
  </div>

  <div class="container-fluid">

    <div class="row-fluid">
      <div class="widget-box">
          <div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
            <h5>问题单列表</h5>
          </div>
          <div class="widget-content nopadding">
            <table id="problem-table" class="table table-bordered">
              <thead>
                <tr>
                  <th>问题单id</th>
                  <th>项目名</th>
                  <th>店铺名</th>
                  <th>执行时间</th>
                  <th>完成状态</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
    			<?php
	        		$connect = mysql_connect("localhost","root","yxs147789");
					if ($connect) {
					  	mysql_select_db("inspectdb", $connect);
					  	mysql_query("set names 'utf8'");
					  	$idResult = mysql_query("SELECT problem_id FROM problem_info WHERE user_name='".$userName."'");
					  	while($id = mysql_fetch_array($idResult)) {
						   $problemResult = mysql_query("SELECT project, store_name, start_time, state  FROM problems WHERE id=".$id["problem_id"]);
						   while($problem = mysql_fetch_array($problemResult)) {
						   		echo '<tr><td>'.$id["problem_id"].'</td>';
						   		echo '<td>'.$problem["project"].'</td>';
						   		echo '<td>'.$problem["store_name"].'</td>';
						   		echo '<td>'.$problem["start_time"].'</td>';
						   		echo '<td>'.$problem["state"].'</td>';
						   		echo '<td><a href="probleminfo.php?id='.$id["problem_id"].'" class="btn btn-info">详细</a></td></tr>';
						   }
						}
					}
					mysql_close($connect);
	        	?>
              </tbody>
            </table>
          </div>
        </div>
    <hr/>
        
</div>

<?php
	require("footer.php");
?>
<script src="js/jquery.dataTables.min.js"></script> 
<script>
	$(document).ready(function(){
		
		$('#problem-table').dataTable({
			"bJQueryUI": true,
			"sPaginationType": "full_numbers",
			"sDom": '<""l>t<"F"fp>'
		});
	});

</script>